<template>
    <d2-container class="forget">
        <template slot="header">
            <el-header class="ft-head">
                <div class="head-show display-flex-between">
                    <div class="log">
                        <span class="title">欢迎您</span>
                    </div>
                    <div class="has-account">
                         <!-- <navbatwo></navbatwo> -->
                    </div>
                </div>
            </el-header>
        </template>

        <el-main>
            <div class="login-input">
                <!--注册成功-->
                <div>
                    <div class="register-in">
                        <span class="register-title">请选择一家企业登录</span>
                    </div>
                    <el-container>
                        <el-row v-if="empListLength > 3" type="flex" justify="center">
                            <el-carousel type="card" :autoplay="false" width="250px" trigger="click">
                                <el-carousel-item v-for="item in empList" :key="item.id">
                                    <div @click="selectAccount(item.id)">
                                        <el-card>
                                            <img class="company-img" src="../../assets/images/forsuccess-b.png">
                                            <span class="company-list company-list-title">{{item.company_name}}</span>
                                            <span class="company-list">{{item.institutional_name}}</span>
                                            <span class="company-list">{{item.unit_name}}</span>
                                        </el-card>
                                    </div>
                                </el-carousel-item>
                            </el-carousel>
                        </el-row>
                        <el-row :gutter="16" v-else type="flex" justify="center">
                            <el-col :span="8" v-for="item in empList" :key="item.id">
                                <div @click="selectAccount(item.id)">
                                    <el-card>
                                        <img class="company-img" src="../../assets/images/forsuccess-b.png">
                                        <span class="company-list company-list-title">{{item.company_name}}</span>
                                        <span class="company-list">{{item.institutional_name}}</span>
                                        <span class="company-list">{{item.unit_name}}</span>
                                    </el-card>
                                </div>
                            </el-col>
                        </el-row>
                    </el-container>
                </div>
            </div>
        </el-main>
    </d2-container>
</template>

<script>
// import Navbatwo from "@/components/UI/Navbatwo";
import storage from "@/utils/storage";
import { throttle } from "../../utils/index";

export default {
  name: "selectAccount",
  components: {
    // Navbatwo
  },
  data() {
    return {
      empList: [],
      selectLoginData: {
        uname: "",
        upwd: "",
        id: ""
      },
      empListLength: 2, /// 获取数组长度
      autoplayState: false
    };
  },
  mounted() {
    this.selectLoginData.uname = storage.getStorage("username");
    this.empList = JSON.parse(storage.getStorage("empList"));
    this.empListLength = this.empList.length;
  },
  methods: {
    selectAccount: throttle(function(id) {
      this.selectLoginData.id = id;
      this.$store.dispatch("d2admin/account/selectByAccount", {
        vm: this,
        payload: this.selectLoginData
      });
    }, 1000)
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.forget {
  .el-carousel {
    width: 644px;
  }
  .company-img {
    width: 136px;
    height: 142px;
    margin: 0 auto;
    display: block;
  }
  .register-in {
    text-align: center;
    .register-title {
      font-weight: bold;
      color: #333;
      line-height: 230px;
      display: inline-block;
      height: 140px;
      padding-left: 146px;
      margin-bottom: 16px;
      background: url(../../assets/images/forsuccess-b.png) no-repeat 0 center;
      background-size: 136px 142px;
    }
  }
  width: 100%;
  .agreements-top {
    .agreements-title {
      font-weight: bold;
    }
    .el-dialog__header {
      border-top: 3px solid #0886ea;
    }
    .agreements-footer {
      border-top: 2px solid #f4f4f4;
      padding-top: 16px;
    }
  }
  /*head*/
  .ft-head {
    width: 100%;
    box-shadow: 4px 4px 2px #e5e5e5;
  }
  .display-flex-between {
    display: flex;
    justify-content: space-between;
  }
  .head-show {
    height: 60px;
    margin: 0 auto;
    line-height: 60px;
    .log {
      height: 60px;
      background: url(../../assets/images/logo_main.png) no-repeat 0 center;
      background-size: 150px 40px;
      .title {
        display: inline-block;
        line-height: 60px;
        font-size: 18px;
        color: #333333;
        margin-left: 158px;
      }
    }
    .has-account {
      width: 60px;
      position: relative;
      float: right;
      cursor: pointer;
      font-size: 14px;
      color: #a9a9a9;
      .tips {
        margin-left: 16px;
        color: #f56a00;
        .right {
          font-size: 20px;
          margin-left: 8px;
        }
      }
    }
  }
  /*body*/
  .el-main {
    min-height: 500px;
    padding: 0 !important;
    .login-input {
      min-height: 500px;
      max-width: 1000px;
      box-sizing: border-box;
      margin: 56px auto 120px auto;
      .adcolor {
        background: #ccc;
        border-color: transparent;
      }
      .company-list {
        display: block;
        font-size: 14px;
        line-height: 32px;
        text-align: center;
      }
      .company-list-title {
        padding-top: 10px;
        font-size: 16px;
        font-weight: bold;
      }
      .login-agreement {
        color: #0886ea;
      }
      .el-row {
        width: 100%;
      }
      .el-card {
        cursor: pointer;
        transition: all 0.3s;
      }
      .el-form {
        width: 600px;
        margin: 0 auto;
      }
      .el-input {
        width: 70%;
      }
      .get-code-button {
        margin-left: 16px;
      }
      .no-radio {
        width: 70%;
        margin-left: 0;
      }
      .toStates {
        background: #ccc !important;
        border: none;
      }
      .el-card {
        font-size: 30px;
        color: #323232;
        .add-padding {
          padding-top: 18px;
          border-top: 1px solid #323232;
        }
      }
      .tips {
        font-size: 12px;
        color: #f46867;
      }
      .ln-font {
        font-size: 16px;
      }
      .authentication {
        text-align: center;
        font-size: 16px;
        color: #666;
        span {
          color: #0886ea;
          margin-left: 4px;
          cursor: pointer;
        }
      }
    }
  }
  .scroll {
    width: 100%;
    height: 360px;
    background-color: #ffffff;
    overflow-x: scroll;
    overflow-y: hidden;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .forgetPwdfoote {
    width: 100%;
    position: absolute;
    bottom: 80px;
    left: 0;
    z-index: 10;
    .foot {
      width: 1200px;
      margin: 0 auto;
      p {
        font-size: 14px;
        text-align: center;
        color: #b8b8b8;
        line-height: 20px;
        height: 20px;
        span {
          padding: 0 8px;
        }
      }
    }
  }
}
</style>
